<template>
    <div class="container">
        <common-header :title="title" />
        <search-input @onSearch="onSearch" /> 
        <search-scroll-wrapper :data="data" />
  
    </div>
</template>

<script>
import CommonHeader from 'components/Header/Common';
import SearchInput from 'components/SearchInput'
import SearchScrollWrapper from 'components/ScrollWrapper/Search';

import tools from 'utils/tools';

export default {
    name: 'Search',
    components: {
        CommonHeader,
        SearchInput,
        SearchScrollWrapper
    },
    data () {
        return {
            title: '商家搜索',
            data: {}
        }
    },
    methods: {
        onSearch (res) {
            if(res && res.status === 0) {
                const data = res.data;
                
                data.status = res.status;
                data.foodDatas = tools.formatJSON(data.foodDatas, 'keyword');
                this.data = data;
            } else {
                this.data = res;
            }
        }
    }
}
</script>

<style lang="scss" scoped>

</style>